/*     */ package com.qmsk.business.task.recommendManRecord.controller;
/*     */ 
/*     */ import com.qmsk.business.task.recommendManRecord.dao.RecommendManRecordDao;
/*     */ import com.qmsk.business.weixin.customMenu.weiXinUtil.WeiXinUtil;
/*     */ import com.qmsk.business.weixin.infoMation.message.resp.Article;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.basic.ObjectComm;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.LinkedHashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.commons.lang.StringUtils;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"recommendMan"})
/*     */ public class RecommendManRecordController
/*     */ {
/*  39 */   private static final Logger logger = Logger.getLogger(RecommendManRecordController.class);
/*     */ 
/*     */   @Autowired
/*     */   private RecommendManRecordDao dao;
/*     */ 
/*     */   public LinkedHashMap<String, Object> collectionData(HttpServletRequest request)
/*     */   {
/*  46 */     LinkedHashMap params = new LinkedHashMap();
/*     */ 
/*  48 */     String recommendedName = RequestUtils.getString(request, 
/*  49 */       "recommendedName");
/*  50 */     String mp = RequestUtils.getString(request, "mp");
/*     */ 
/*  52 */     if (!(StringUtils.isEmpty(mp))) mp.length();
/*     */ 
/*  56 */     Short type = RequestUtils.getShort(request, "type");
/*  57 */     String memo = RequestUtils.getString(request, "memo");
/*  58 */     Short status = RequestUtils.getShort(request, "status");
/*  59 */     Integer giveIntegral = RequestUtils.getInt(request, "giveIntegral");
/*  60 */     Double rebateAmount = RequestUtils.getDouble(request, "rebateAmount");
/*     */ 
/*  62 */     return params;
/*     */   }
/*     */ 
/*     */   public void bsInsert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"insert/insertInfo"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/*  82 */       int nResult = 0;
/*  83 */       String sData = RequestUtils.getStringOfData(request);
/*  84 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/*  85 */       if ((p != null) && (p.isExistsInsertRows())) {
/*  86 */         GsonHeadOneRow g = (GsonHeadOneRow)p.getListInsertRows().get(0);
/*  87 */         g.autoAddHeadData("createdTime", new Date());
/*  88 */         g.autoAddHeadData("Status", Integer.valueOf(0));
/*  89 */         nResult = this.dao.applyUpdates(p);
/*  90 */         if (nResult > 0) {
/*  91 */           String customerName = ObjectComm.objectToString(g
/*  92 */             .getValueOfName("recommendName"));
/*  93 */           String openId = ObjectComm.objectToString(
/*  94 */             RequestUtils.getString(request, "openId"));
/*  95 */           if (openId != null) {
/*  96 */             List news = new ArrayList();
/*  97 */             Article article = new Article();
/*  98 */             article.setSendNewsTitle("客户推荐受理通知");
/*  99 */             article.setSendNewsDescription("尊敬的" + customerName + 
/* 100 */               ":我们已收到您的推荐客户信息，感谢您的参与！");
/* 101 */             article.setSendNewsPicUrl(null);
/* 102 */             article.setSendNewsUrl(null);
/* 103 */             news.add(article);
/* 104 */             if (StringUtils.isNotEmpty(openId)) {
/* 105 */               WeiXinUtil.sendNewsMessageOfMain(news, openId);
/*     */             }
/*     */           }
/* 108 */           DbConnection.commit();
/*     */         } else {
/* 110 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 113 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 114 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 115 */         response);
/*     */     } catch (Exception e) {
/* 117 */       logger.error(e);
/* 118 */       DbConnection.rollback();
/* 119 */       ResponseUtils.setErrorMsgResponse(
/* 120 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 121 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/recommendList/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListShopIdOpt(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 130 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 132 */       Map params = new HashMap();
/* 133 */       MapUtils.addToMap(params, "id", RequestUtils.getStringOfId(request));
/* 134 */       String shopId = RequestUtils.getString(request, "shopId");
/* 135 */       String openId = RequestUtils.getString(request, "openId");
/* 136 */       MapUtils.addToMap(params, "shopId", shopId);
/* 137 */       MapUtils.addToMap(params, "openId", openId);
/* 138 */       MapUtils.addPercentToMap(params, "memberId", 
/* 139 */         RequestUtils.getString(request, "memberId"));
/* 140 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params, nPageIdx, 
/* 141 */         nPageSize);
/* 142 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 144 */       logger.error(e);
/* 145 */       ResponseUtils.setErrorMsgResponse(
/* 146 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 162 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 164 */       String[] strParams = id.split(",");
/* 165 */       int nResult = this.dao.deleteParams(strParams);
/* 166 */       if (nResult > 0)
/* 167 */         DbConnection.commit();
/*     */       else {
/* 169 */         DbConnection.rollback();
/*     */       }
/* 171 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 172 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 173 */         response);
/*     */     } catch (Exception e) {
/* 175 */       DbConnection.rollback();
/* 176 */       logger.error(e);
/* 177 */       ResponseUtils.setErrorMsgResponse(
/* 178 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 179 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.task.recommendManRecord.controller.RecommendManRecordController
 * JD-Core Version:    0.5.3
 */